home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / mweb / MWEB Utils / ws295sdk.exe / Ws2sdkzp.exe / SAMPLES / LAYERED / DBUFFMGR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-06  |  5.5 KB  |  224 lines

  1. /*++
  2.  
  3.      Copyright (c) 1996 Intel Corporation
  4.      Copyright (c) 1996 Microsoft Corporation
  5.      All Rights Reserved
  6.  
  7.      Permission is granted to use, copy and distribute this software and
  8.      its documentation for any purpose and without fee, provided, that
  9.      the above copyright notice and this statement appear in all copies.
  10.      Intel makes no representations about the suitability of this
  11.      software for any purpose.  This software is provided "AS IS."
  12.  
  13.      Intel specifically disclaims all warranties, express or implied,
  14.      and all liability, including consequential and other indirect
  15.      damages, for the use of this software, including liability for
  16.      infringement of any proprietary rights, and including the
  17.      warranties of merchantability and fitness for a particular purpose.
  18.      Intel does not assume any responsibility for any errors which may
  19.      appear in this software nor any responsibility to update it.
  20.  
  21. Module Name:
  22.  
  23. dbuffmgr.cpp
  24.  
  25. Abstract:
  26.  
  27.      This module defines and interface for a buffer manager for managing
  28.      WSABUF's.  If a layered provider needs to modify application data The
  29.      CopyBuffer() routine should be modifed to do so.
  30.  
  31. --*/
  32.  
  33. #include "precomp.h"
  34.  
  35.  
  36.  
  37. DBUFFERMANAGER::DBUFFERMANAGER(
  38.     )
  39. /*++
  40.  
  41. Routine Description:
  42.  
  43.     DBUFFERMANAGER  object  constructor.   Creates and returns a DBUFFERMANAGER
  44.     object.  Note that  the  DBUFFERMANAGER object has not been fully
  45.     initialized.  The "Initialize" member function must be the first member
  46.     function called on the new DBUFFERMANAGER object.
  47.  
  48. Arguments:
  49.  
  50.     None
  51.  
  52. Return Value:
  53.  
  54.     None
  55. --*/
  56. {
  57.     // Null function body.  A full implemantation would initialize member
  58.     // varialbles to know values for use in Initailize().
  59. }
  60.  
  61.  
  62.  
  63.  
  64. INT
  65. DBUFFERMANAGER::Initialize(
  66.         )
  67. /*++
  68.  
  69. Routine Description:
  70.  
  71.     The initialization routine for a buffer manager object.  This procedure
  72.     completes the initialzation of the object.  This procedure preforms
  73.     initialization operations that may fail and must be reported since there is
  74.     no way to fail the constructor.
  75.  
  76. Arguments:
  77.  
  78.     None
  79. Return Value:
  80.  
  81.     The  function returns NO_ERROR if successful.  Otherwise it
  82.     returns an appropriate WinSock error code if the initialization
  83.     cannot be completed.
  84. --*/
  85. {
  86.     return(NO_ERROR);
  87. }
  88.  
  89.  
  90.  
  91. DBUFFERMANAGER::~DBUFFERMANAGER()
  92. /*++
  93.  
  94. Routine Description:
  95.  
  96.     DBUFFERMANAGER object destructor.  This procedure has the responsibility to
  97.     perform any required shutdown operations for the DBUFFERMANAGER object
  98.     before the object memory is deallocated.
  99.  
  100. Arguments:
  101.  
  102.     None
  103.  
  104. Return Value:
  105.  
  106.     None
  107. --*/
  108. {
  109.     // Null function body
  110. }
  111.  
  112. INT
  113. DBUFFERMANAGER::AllocBuffer(
  114.     IN  LPWSABUF   UserBuffer,
  115.     IN  DWORD      UserBufferCount,
  116.     OUT LPWSABUF*  InternalBuffer,
  117.     OUT DWORD*     InternalBufferCount
  118.     )
  119. /*++
  120.  
  121. Routine Description:
  122.  
  123.     This routine allocates a set of WSABUF's to pass to the underlying service
  124.     provider.
  125.  
  126. Arguments:
  127.  
  128.     UserBuffer - A pointer to the array user WSABUFs
  129.     UserBufferCount - The number of user WSABUF structs.
  130.     InternalBuffer - A pointer to a pointer to a WSABUF
  131.     InternalBufferCount - The pointer to a DWORD to revceive the number of
  132.                           WSABUFs pointed to by InternalBuffer.
  133.  
  134.  
  135. Return Value:
  136.  
  137.     The  function returns NO_ERROR if successful.  Otherwise it
  138.     returns an appropriate WinSock error code if the initialization
  139.     cannot be completed.
  140.  
  141. --*/
  142. {
  143.     // ******
  144.     // Note this procedure returns the user buffer(s) undistrubed.  This is the
  145.     // wrong thing for providers that wish to modify the data stream.  The
  146.     // proper buffer management policy is left to the provider developer.
  147.     *InternalBuffer = UserBuffer;
  148.     *InternalBufferCount = UserBufferCount;
  149.     return(NO_ERROR);
  150. }
  151.  
  152.  
  153. VOID
  154. DBUFFERMANAGER::FreeBuffer(
  155.     IN LPWSABUF  InternalBuffer,
  156.     IN DWORD     InternalBufferCount
  157.     )
  158. /*++
  159.  
  160. Routine Description:
  161.  
  162.     This routine frees a set of WSABUF's allocated by AllocBuffer();
  163.  
  164. Arguments:
  165.  
  166.     InternalBuffer - A pointer to WSABUF array
  167.     InternalBufferCount - The number of WSABUFs pointed to by InternalBuffer.
  168.  
  169.  
  170. Return Value:
  171.  
  172.     The  function returns NO_ERROR if successful.  Otherwise it
  173.     returns an appropriate WinSock error code if the initialization
  174.     cannot be completed.
  175.  
  176. --*/
  177. {
  178. }
  179.  
  180.  
  181. INT
  182. DBUFFERMANAGER::CopyBuffer(
  183.     IN  LPWSABUF   SourceBuffer,
  184.     IN  DWORD      SourceBufferCount,
  185.     IN  DWORD       SourceOffset,
  186.     IN    DWORD       BytesToCopy,
  187.     IN  LPWSABUF   DestinationBuffer,
  188.     IN  DWORD      DestinationBufferCount,
  189.     IN  DWORD       DestionationOffset
  190.     )
  191. /*++
  192.  
  193. Routine Description:
  194.  
  195.     This routine copies one set of WSABUFs to another.
  196.  
  197. Arguments:
  198.  
  199.     SourceBuffer - A pointer to an array of WSABUFs.
  200.  
  201.     SourceBuferCount - The number of WSABUFs pointed to by SourceBuffer.
  202.  
  203.     SourceOffset      - offset to start copying from in source
  204.     BytesToCopy          - maximum number of bytest to copy
  205.     DestinationBuffer - A pointer to an array of WSABUFs.
  206.  
  207.     DestinationBufferCount - The number of WSABUFs pointed to by
  208.                              DestinationBuffer .
  209.     DestinationOffset - offset to start writing to in destionation buffer
  210.  
  211. Return Value:
  212.  
  213.     The  function returns NO_ERROR if successful.  Otherwise it
  214.     returns an appropriate WinSock error code if the initialization
  215.     cannot be completed.
  216.  
  217. --*/
  218. {
  219.     return(NO_ERROR);
  220. }
  221.  
  222.  
  223.  
  224.